#include <iostream>
#include <set>
using namespace std;

class Solution
{
public:
    bool isHappy(int n)
    {
        set<int> seen;
        while (true)
        {
            if (n == 1)
                return true;
            if (seen.find(n) != seen.end())
                return false;
            seen.insert(n);
            n = getNext(n);
        }
    }

    int getNext(int n)
    {
        int sum = 0;
        while (n != 0)
        {
            int digit = n % 10;
            sum += digit * digit;
            n = n / 10;
        }
        return sum;
    }
};

int main()
{
    cout << "Code202" << endl;
    Solution s;
    return 0;
}